Imports System
Imports Microsoft.VisualBasic
Namespace flspartnerweb

  Partial Class logIn_aspx_vb
        Inherits Functions
    Public username As String 
    Public password As String 
    Public pwd As Object ' System.Object
    Public loginID As Object 
    Public loginType As String 
        Public strSQL As String


        Protected Overrides Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            Response.Buffer = True
            Session.LCID = 1053
            username = Request.Form("username")
            password = Request.Form("password")
            If Len(username) > 0 Then
                username = Trim(username)
                username = Replace(username, " ", "")
                username = Replace(username, "'", "")
                username = Replace(username, """", "")
                username = Replace(username, "<", "")
                username = Replace(username, ">", "")
                username = Replace(username, "=", "")
            End If
           
            If Len(username) > 0 Then
                If Len(username) < 2 Then
                    Response.Redirect("default.aspx?error=1")
                End If
                If Left(username, 1) = "p" Then
                    loginID = Mid(username, 2)
                    loginType = "p"
                    If IsNumeric(loginID) = True Then
                        strSQL = "Select partnerID As loginID, pwd From tblPartner Where partnerID = " & loginID & ""
                    Else
                        Response.Redirect("default.aspx?error=2")
                    End If
                ElseIf Left(username, 2) = "de" Then
                    loginID = Mid(username, 3)
                    loginType = "de"
                    If IsNumeric(loginID) = True Then
                        strSQL = "Select dealerEmployeeID As loginID, pwd From tblDealerEmployee Where dealerEmployeeID = " & loginID & ""
                    Else
                        Response.Redirect("default.aspx?error=3")
                    End If
                ElseIf Left(username, 1) = "d" Then
                    loginID = Mid(username, 2)
                    loginType = "d"
                    If IsNumeric(loginID) = True Then
                        strSQL = "Select dealerID As loginID, pwd From tblDealer Where dealerID = " & loginID & ""
                    Else
                        Response.Redirect("default.aspx?error=4")
                    End If
                Else
                    Response.Redirect("default.aspx?error=5")
                End If
                Response.Write("loginID = " & loginID & "<br>")
                Response.Write("loginType = " & loginType & "<br>")
                Response.Write("password = " & password & "<br>")
                If Len(password) > 0 Then
                    dbOpen()
                    Response.Write("" & strSQL & "<br>")
                    RecSet = Conn.Execute("" & strSQL & "")
                    If RecSet.EOF Then
                        Response.Redirect("default.aspx?error=6")
                    Else
                        loginID = RecSet.Fields("loginID").Value
                        pwd = RecSet.Fields("pwd").Value
                        If LCase(password) = LCase(pwd) Then
                            Session.Add("flsPartnerWebID", loginID)
                            Session.Add("flsPartnerWebType", loginType)
                            Session.Timeout = 120
                            Response.Redirect("userInside.aspx")
                            Response.Write("loginID = " & loginID & "<br>")
                            Response.Write("loginType = " & loginType & "<br>")
                        Else
                            Response.Redirect("default.aspx?error=7")
                        End If
                    End If
                    RecSet.Close()
                    RecSet = Nothing
                    dbClose()
                Else
                    Response.Redirect("default.aspx?error=8")
                End If
            Else
                Response.Redirect("default.aspx?error=9")
            End If
        End Sub



       


    End Class
End Namespace
